package com.moss.web;

import com.github.pagehelper.PageInfo;
import com.moss.common.core.BaseController;
import com.moss.common.domain.AjaxResult;
import com.moss.common.entity.SysTaskEntity;
import com.moss.common.util.DateTimeUtil;
import com.moss.common.util.IdUtil;
import com.moss.system.service.TaskService;
import lombok.Data;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/task")
public class TaskController extends BaseController {

    @Resource
    TaskService taskService;


    @GetMapping("/list")
    public AjaxResult<List<SysTaskEntity>> list(SysTaskEntity task){
        startPage();
        List<SysTaskEntity> list = taskService.getTaskList(task);
        return AjaxResult.success(list,new PageInfo<>(list).getTotal());
    }


    @GetMapping("/{taskId}")
    public AjaxResult<SysTaskEntity> getTask(@PathVariable String taskId){
        return AjaxResult.success(taskService.getTask(taskId));
    }


    @GetMapping("/randomTaskNo")
    public AjaxResult<String> randomTaskNo(){
        return AjaxResult.success(IdUtil.randomTaskNo());
    }
}
